package com.own.component.mybatis.hook;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.own.component.mybatis.injector.method.InsertBatch;
import com.own.component.mybatis.injector.method.InsertIgnore;
import com.own.component.mybatis.injector.method.MaxSortOrder;
import com.own.component.mybatis.injector.method.MinSortOrder;
import com.own.component.mybatis.injector.method.UpdateByIdBatch;
import com.own.component.mybatis.injector.method.UpdateDecreaseOrder;
import com.own.component.mybatis.injector.method.UpdateIncreaseOrder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * DefaultCustomMybatisHookImpl
 *
 * @author chenxueli
 * @date 2024-01-12 11:52:00
 */
@Slf4j
@Component
public class DefaultCustomMybatisHookImpl implements CustomMybatisHook {

    /**
     * 执行方法
     *
     * @param methodList  方法列表
     * @param mapperClass mapper类
     * @param tableInfo   表信息
     */
    @Override
    public void run(List<AbstractMethod> methodList, Class<?> mapperClass, TableInfo tableInfo) {
        methodList.add(new InsertBatch());
        methodList.add(new InsertIgnore());
        methodList.add(new UpdateByIdBatch());
        methodList.add(new MaxSortOrder());
        methodList.add(new MinSortOrder());
        methodList.add(new UpdateDecreaseOrder());
        methodList.add(new UpdateIncreaseOrder());
    }

    /**
     * 执行的顺序，数字越小越先执行
     *
     * @return 顺序
     */
    @Override
    public int order() {
        return -999;
    }

}
